from langgraph.graph import StateGraph, START, END
from langgraph.checkpoint.memory import MemorySaver


from src.graph.state import State
from src.graph.nodes import (
    coordinator_node,
    planner_node,
    background_investigation_node
)

# 这是一个没有持久化记忆的graph
def _build_base_graph():
    """Build and return the base state graph with all nodes and edges."""
    builder = StateGraph(State)
    builder.add_edge(START, "coordinator")
    builder.add_node("coordinator", coordinator_node)
    builder.add_node("background_investigator",background_investigation_node)
    builder.add_node("planner", planner_node)
    builder.add_edge("background_investigator", "planner")
    builder.add_edge("coordinator", END)
    return builder


def build_graph():
    """Build and return the agent workflow graph without memory."""
    # build state graph
    builder = _build_base_graph()
    return builder.compile()

graph = build_graph()